import { isNullOrUndefined } from "util";
import * as moment from 'moment';

export class GanttProjectModel {
    public id: string;
    public parentId: string;
    public calendars: any = [];
    public creationDate: string;
    public title: string;
    public company: string;
    public author: string;
    public startDate: any;
    public finishDate: any;
    public dateFormat: any = [];
    public bindingInfo: any;
    public constructor(param) {
        (!isNullOrUndefined(param.id)) && (this.id = param.id);
        (!isNullOrUndefined(param.parentId)) && (this.parentId = param.parentId);
        (!isNullOrUndefined(param.calendars)) && (this.calendars = param.calendars);
        (!isNullOrUndefined(param.creationDate)) && (this.creationDate = param.creationDate);
        (!isNullOrUndefined(param.title)) && (this.title = param.title);
        (!isNullOrUndefined(param.company)) && (this.company = param.company);
        (!isNullOrUndefined(param.author)) && (this.author = param.author);
        (!isNullOrUndefined(param.startDate)) && (this.startDate = param.startDate);
        (!isNullOrUndefined(param.finishDate)) && (this.finishDate = param.finishDate);
        (!isNullOrUndefined(param.bindingInfo)) && (this.bindingInfo = param.bindingInfo);
        (!isNullOrUndefined(param.dateFormat)) && (this.dateFormat = param.dateFormat);
    }

    public toCreateJson() {
        return {
            Title: this.title,
            Company: this.company,
            Author: this.author,
            StartDate: moment(this.dateFormat[0]).toJSON(),
            FinishDate: moment(this.dateFormat[1]).toJSON()
        };
    }
}

export interface ITask {
    active: number;
    actualCost: number;
    actualDuration: any;
    actualFinish: any;
    actualOvertimeCost: number;
    actualOvertimeWork: any;
    actualOvertimeWorkProtected: any;
    actualStart: any;
    actualWork: any;
    actualWorkProtected: any;
    acwp: number;
    baseline: any[];
    baselineUUIDs: any;
    bcwp: number;
    bcws: number;
    calendarUID: number;
    commitmentFinish: any;
    commitmentStart: any;
    commitmentType: number;
    constraintDate: any;
    constraintType: number;
    contact: any;
    cost: number;
    createDate: string;
    critical: boolean;
    cv: number;
    deadline: any;
    duration: string;
    durationFormat: number;
    earlyFinish: any;
    earlyStart: any;
    earnedValueMethod: number;
    effortDriven: boolean;
    enabled: boolean;
    estimated: boolean;
    extendedAttribute: any[];
    extendedAttributeUUIDs: any;
    externalTask: boolean;
    externalTaskProject: any;
    finish: string;
    finishVariance: number;
    fixedCost: number;
    fixedCostAccrual: any;
    freeSlack: number;
    hideBar: boolean;
    hyperlink: any;
    hyperlinkAddress: any;
    hyperlinkSubAddress: any;
    id: string;
    ignoreResourceCalendar: boolean;
    isNull: boolean;
    isPublished: boolean;
    isSubproject: boolean;
    isSubprojectReadOnly: boolean;
    lateFinish: any;
    lateStart: any;
    levelAssignments: boolean;
    levelingCanSplit: boolean;
    levelingDelay: number;
    levelingDelayFormat: number;
    manual: number;
    milestone: boolean;
    name: string;
    notes: any;
    outlineLevel: number;
    outlineNumber: any;
    overAllocated: boolean;
    overtimeCost: number;
    overtimeWork: any;
    parentId: string;
    percentComplete: number;
    percentWorkComplete: number;
    physicalPercentComplete: number;
    preLeveledFinish: any;
    preLeveledStart: any;
    predecessorLink: any[];
    predecessorLinkUUIDs: any;
    priority: number;
    recurring: boolean;
    regularWork: any;
    remainingCost: number;
    remainingDuration: any;
    remainingOvertimeCost: number;
    remainingOvertimeWork: any;
    remainingWork: any;
    resume: any;
    resumeValid: boolean;
    rollup: boolean;
    starVariance: number;
    start: string;
    statusmanager: any;
    stop: any;
    subprojectName: any;
    summary: boolean;
    totalSlack: number;
    type: number;
    uid: number
    wbs: string;
    wbsLevel: any;
    work: any;
    workVariance: number;
    _ID: number;
}

export interface IExtendAttr {
    alias: any;
    appendNewValues: boolean;
    autoRollDown: boolean;
    calculationType: number;
    cfType: number;
    default: any;
    defaultGuid: any;
    elemType: number;
    enabled: boolean;
    fieldID: string;
    fieldName: string;
    formula: any;
    id: string;
    ltuid: any;
    maxMultiValues: number;
    parentId: string;
    phoneticAlias: any;
    restrictValues: boolean;
    rollupType: number;
    secondaryPID: any;
    userDef: boolean;
    valuelistSortOrder: number;
    _Guid: any;
}

